<template>
  <el-container class="all">
    <el-header>
      <el-row class="header">
        <el-col :span="5">
          <div class="title">
            <el-avatar
              src="http://localhost:3000/upload/aniya.jpg"
              :size="60"
            ></el-avatar>
          </div>
        </el-col>
        <el-col :span="14">
          <div class="classify">
            <ul>
              <b>
                <li><router-link to="/list">分类</router-link></li>
                <li><router-link to="/message">留言</router-link></li>
                <li><router-link to="/echart">数据</router-link></li>
                <li><router-link to="/alllist">全部</router-link></li>
                <li><router-link to="/about">联系我们</router-link></li>
              </b>
            </ul>
          </div>
        </el-col>
        <el-col :span="5">
          <div class="load">
            <el-button type="primary" size="middle" @click="handleClick"
              >登录</el-button
            >
          </div>
        </el-col>
      </el-row>
    </el-header>
    <el-main>
      <div class="block">
        <el-carousel height="70vh">
          <el-carousel-item v-for="item in items" :key="item.id">
            <router-link :to="`/detail?id=${item.id}`" class="router">
              <img :src="item.imgPath" class="imgshow" />
              <h2>
                {{ item.title }}
              </h2>
            </router-link>
          </el-carousel-item>
        </el-carousel>
      </div>
    </el-main>
  </el-container>
</template>

<script>
// @ is an alias to /src

export default {
  name: 'Home',
  data() {
    return {
      items: [],
    }
  },
  created() {
    this.$api.getMostArticle().then((res) => {
      this.items = res.data.result
    })
  },
  methods: {
    handleClick() {
      window.location.href = 'http://localhost:8080/login'
    },
  },
}
</script>

<style scoped>
a {
  text-decoration: none;
}
.all {
  min-width: 800px !important;
}
.router-link-active {
  text-decoration: none;
}
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100px;
  line-height: 100px;
}
el-avatar {
  height: 50px;
  width: 50px;
  margin-right: 100px;
  line-height: 50px;
}
.el-col {
  display: flex;
  justify-content: center;
}
.title {
  margin-top: 40px;
}
.classify {
  display: block;
}
li {
  float: left;
  list-style: none;
  padding: 20px;
  line-height: 30px;
  font-size: 24px;
  font-family: KaiTi;
}
.el-dropdown-link {
  width: 120px;
  font-size: 24px;
  cursor: pointer;
  color: #d3dce6;
}
.el-icon-arrow-down {
  font-size: 16px;
}
.demonstration {
  display: block;
  color: #8492a6;
  font-size: 14px;
  margin-bottom: 20px;
}
.search {
  margin: 20px;
  line-height: 50px;
}
.load {
  margin: 20px;
  line-height: 50px;
}
.el-main {
  margin: 40px auto;
  width: 80vw;
  height: 80vh;
  min-width: 800px;
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  /* line-height: 160px; */
}
.el-carousel__item:nth-child(4n) {
  /* background-image: url('../assets/images/aniya5.jpg'); */
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
  background-color: #fff;
}

.el-carousel__item:nth-child(4n + 1) {
  /* background-image: url('../assets/images/aniya6.jpg'); */
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
  background-color: #fff;
}
.el-carousel__item:nth-child(4n + 2) {
  /* background-image: url('../assets/images/aniya7.jpg'); */
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
  background-color: #fff;
}
.el-carousel__item:nth-child(4n + 3) {
  /* background-image: url('../assets/images/aniya4.jpg'); */
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
  background-color: #fff;
}
.router {
  position: relative;
  /* display: flex; */
  /* padding: 350px 300px 0px 650px; */
  text-decoration: none;
  font-size: 18px;
  color: #8492a6;
}
.router h2 {
  position: absolute;
  left: 50%;
  bottom: 70px;
  padding: 15px;
  transform: translateX(-50%);
  color: skyblue;
  background-color: rgba(0, 0, 0, 0.5);
}
.imgshow{
  height: 100%;
}
</style>
